#!/bin/bash
testdir=$(cd $(dirname $0)/; pwd)
workdir=$(dirname $testdir)
cd $workdir

cfg=./cfg.json
httpport=`cat cfg.json | grep -A3 "\"http\":" | grep "\"listen\"" | cut -d\" -f4 | cut -d: -f2`
httpprex="127.0.0.1:$httpport"

function http_push(){
    e="e.niean"
    m="m.niean"
    t="t0=tag0,t1=tag1"
    ts=`date +%s`
    val=`expr $ts / 60 % 10`
    curl -s -X POST -d "[{\"metric\":\"$m\", \"endpoint\":\"$e\", \"timestamp\":$ts,\"step\":60, \"value\":$val, \"counterType\":\"GAUGE\",\"tags\":\"$t\"}]" "$httpprex/api/push" | python -m json.tool
}

http_push
